package Fail3_17;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class FileDemo4 {
    public static void main(String[] args) {
        try(InputStream inputStream=new FileInputStream("./hello.txt")) {
            byte[] buffer=new byte[1024];
            while (true){
                int len =inputStream.read(buffer);
                if(len==-1){
                    break;
                }
                for (int i = 0; i < len; i++) {
                    System.out.printf("%c",buffer[i]);
                }
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
//    public static void main(String[] args) throws IOException {
//        InputStream inputStream = new FileInputStream("./hello.txt");
//        while (true) {
//            int b = inputStream.read();
//            if (b == -1) {
//                break;
//            }
//            System.out.printf("%c", b);
//        }
//        inputStream.close();
//    }
}
